<template>
	<view class="record">
		<view class="list">
			<view class="huozhu" v-for="(item,index) in list" :key="index">
				<view class="hzInfo dFlex jStart_aCenter">
					<view class="hzTx imgPublic">
						<image :src="item.image_head" mode="widthFix"></image>
					</view>
					<view class="info">
						<view class="user dFlex jBetween_aCenter">
							<view><text>{{item.nickName}}</text></view>
							<view class="price">
								报价 ￥<text>{{item.ton_price}}</text>/吨
							</view>
						</view>
						<view class="time">{{item.time1}}用户 · {{item.time2}}活跃</view>
					</view>
				</view>
				<view class="price_time dFlex jBetween_aCenter">
					<text>报价时间: {{item.create_time}}</text>
					<view class="btn" @click="agreePrice(item)">
						同 意
					</view>
				</view>
			</view>
		</view>
		<!-- <u-empty v-if='!list.length' mode="data" text='暂无数据' :marginTop='30'> </u-empty> -->
	</view>
</template>

<script>
	import {
		offerList,
		indexOperate,
	} from '@/tool/http.js';
	export default {
		data() {
			return {
				id:'',
				list:[],
				haveMore:false,
				page:1,
			};
		},
		onLoad(e) {
			this.id = e.id;
			this.initList();
		},
		onReachBottom() {
			if(this.haveMore){
				this.haveMore = false;
				this.initList(this.page++);
			}
		},
		methods:{
			// 同意报价
			async agreePrice(line){
				uni.showModal({
					title:'确定同意该司机的报价?',
					success: async(op) => {
						let res = await indexOperate({
							id:line.id,
							type:'3', 
							status:'1',
						});
						if(res){
							uni.showToast({
								title:'已同意报价',
								icon:'success'
							});
							setTimeout(()=>{
								uni.navigateBack({
									delta:1
								})
							},1650)
						}
					}
				})
			},
			async initList(page){
				this.page = page ? page : this.page;
				let res = await offerList({
					page:this.page,
					id:this.id,
				});
				console.log(res);
				if(res){
					this.$set(this,'list',this.page == 1 ? res.list : this.list.concat(res.list));
					this.haveMore = res.list.length >= 10 ? true : false;
				}
			}
		}
	}
</script>

<style lang="scss">
	.huozhu{
		.price_time{
			.btn{
				width: max-content;
				padding: 5px 12px;
				color: white;
				font-size: 14px;
				background: #0087FC;
				border-radius: 50px;
			}
			width:100%;
			font-size: 12px;
			color: #999999;
		}
		.hzInfo{
			.info{
				.price{
					text{
						font-weight: bold;
					}
				}
				.line{
					display: inline-block;
					margin:0 5px;
				}
				.time{
					font-size: 12px;
					color: #999999;
					margin-top: 3px;
				}
				flex: 1;
			}
			.hzTx{
				width:40px;
				height:40px;
				border-radius: 50%;
				margin-right: 12px;
			}
			width: 100%;
			margin-bottom: 12px;
			padding-bottom: 12px;
			border-bottom: 1px solid #EEEEEE;
		}
		width: 100%;
		margin: 0 auto 12px;
		padding: 12px;
		box-sizing: border-box;
		background: white;
		border-radius: 4px;
	}
	.record{
		width: 100%;
		padding: 12px;
		box-sizing: border-box;
	}
</style>
